﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MySql.Data.MySqlClient;
using MySql.Data.Types;
using TAMS;


namespace TAMS.RA
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        MySqlConnection conn;
        MySqlCommand sqlCommand;
        MySqlDataReader readVals;
        string strProvider = Resource1.databaseConnection;
        string id;


        protected void Page_Load(object sender, EventArgs e)
        {
            ((Menu)Master.FindControl("Menu1")).Items[1].Selected = true;
            
            id = (string)Session["userName"];
            if (id == null)
                Response.Redirect("../login.aspx");

            if (GridView1.Rows.Count == 0)
                Label1.Visible = true;
            else Label1.Visible = false;

        }

        protected void Button1_Click(object sender, EventArgs e)
        {

        }



        protected void delete_click(object sender, EventArgs e)
        {
            GridViewRow clickedRow = ((Button)sender).NamingContainer as GridViewRow;

             string exid = clickedRow.Cells[1].Text;
             string secCorsId = clickedRow.Cells[6].Text;
             
            conn = new MySqlConnection(strProvider);
            conn.Open();


            string strSQL = "DELETE FROM Proctors" +
               " WHERE secCorsId = " + secCorsId +
                   " AND exId = " + exid;
            sqlCommand = new MySqlCommand(strSQL, conn);
            sqlCommand.ExecuteNonQuery();

            conn.Close();
          // GridView1.FindControl("exId").se

            Response.Redirect("RA_Assigned.aspx");

        }

        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }
    }
}